﻿<%@ WebHandler Language="C#" Class="TypeEditName" %>

using System;
using System.Web;
using System.Data;
using System.Data.Common;
using System.Web.SessionState;

public class TypeEditName : IHttpHandler, IRequiresSessionState
{

    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";

        /* 管理员信息验证 */
        if (!Admins.IsLogin(true))
            Utils.ShowEnd(context, -2);

        /* jieshoubianliang */
        int item_lang = Convert.ToInt32(context.Request.Params["item_lang"].ToString().Trim());
        int r_id = Convert.ToInt32(context.Request.Params["r_id"].ToString().Trim());
        int obj_type = Convert.ToInt32(context.Request.Params["obj_type"].ToString().Trim());
        string type_name = context.Request.Params["type_name"].ToString().Trim();

        /*验证*/
        Verification ver = new Verification();
        if (!ver.VerificationMinMaxValue(item_lang, 1, 255))
            Utils.ShowEnd(context,-1);
        if (type_name.Length<1)
            Utils.ShowEnd(context,-1);
        if (r_id<0)
            Utils.ShowEnd(context,-1);
        Types types = new Types();
        int rights = 0;
        foreach (string type in type_name.Split('\n'))
        {
            if (type.Trim().Length > 0)
            {
                types.Add(type, obj_type, item_lang, r_id);
                rights++;
            }
        }
        
        Utils.ShowEnd(context, rights);
    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }

}